package com.hsl.study.controller;

import cn.hutool.core.date.DateUtil;
import com.hsl.study.service.AiAssistant;
import com.hsl.study.service.ChatAssistant;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class ChatLanguageModelController
{
    @Resource
    private ChatAssistant chatAssistant;
    @Resource
    private AiAssistant aiAssistant;


    @GetMapping(value = "/chatmemory/test1")
    public String testWithOutChatMemory()
    {

        String chat = chatAssistant.chat("你好，我的名字叫张三");
        System.out.println("chat返回结果："+chat);

        String chat2 = chatAssistant.chat("我的名字是什么");
        System.out.println("chat2返回结果："+chat2);

        return "success : "+ DateUtil.now();
    }




    @GetMapping(value = "/chatmemory/test2")
    public String testWithChatMemory()
    {
        aiAssistant.chat(1L, "你好！我的名字是Java.");
        aiAssistant.chat(3L, "你好！我的名字是C++");

        String chat = aiAssistant.chat(1L, "我的名字是什么");
        System.out.println(chat);
        chat = aiAssistant.chat(3L, "我的名字是什么");
        System.out.println(chat);

        return "testWithChatMemory success : "+ DateUtil.now();
    }
}